﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace FwProject.Migrations.FwProjectAppShopDb
{
    public partial class Update_To_appshop : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "EvaluateStatus",
                table: "shop_order_details",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<byte>(
                name: "Returngoods",
                table: "shop_order_details",
                nullable: false,
                defaultValue: (byte)0);

            migrationBuilder.AddColumn<Guid>(
                name: "ProductTypeId",
                table: "shop_coupon",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "ShopSkuId",
                table: "shop_car",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<int>(
                name: "AdTypeLocation",
                table: "shop_Ad_location",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.CreateTable(
                name: "CommodityReviews",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Productid = table.Column<Guid>(nullable: false),
                    Reviewsid = table.Column<long>(nullable: false),
                    ReviceName = table.Column<string>(maxLength: 200, nullable: true),
                    RevicwsContent = table.Column<string>(maxLength: 1000, nullable: false),
                    CommentScore = table.Column<int>(nullable: false),
                    IsShow = table.Column<bool>(nullable: false),
                    OrderId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommodityReviews", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CommodityReviewsImage",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Productid = table.Column<Guid>(nullable: false),
                    ImagePath = table.Column<string>(nullable: false),
                    CommodityReviewsId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CommodityReviewsImage", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CommodityReviewsImage_CommodityReviews_CommodityReviewsId",
                        column: x => x.CommodityReviewsId,
                        principalTable: "CommodityReviews",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CommodityReviewsImage_CommodityReviewsId",
                table: "CommodityReviewsImage",
                column: "CommodityReviewsId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CommodityReviewsImage");

            migrationBuilder.DropTable(
                name: "CommodityReviews");

            migrationBuilder.DropColumn(
                name: "EvaluateStatus",
                table: "shop_order_details");

            migrationBuilder.DropColumn(
                name: "Returngoods",
                table: "shop_order_details");

            migrationBuilder.DropColumn(
                name: "ProductTypeId",
                table: "shop_coupon");

            migrationBuilder.DropColumn(
                name: "ShopSkuId",
                table: "shop_car");

            migrationBuilder.DropColumn(
                name: "AdTypeLocation",
                table: "shop_Ad_location");
        }
    }
}
